// main() {
//   Person p =  Person.createInfo(name: "老不死的高总", age: 34);
//   // Person p =  Person("老不死的高总", 34, "男");
//   // p.age = 20;
//   // p.username = "老高";
//    p.eat();
//    p.run();
//    p.sleep();
//    print(p._name);
  

// }



// 类的使用

class Person {
  String username = "";
  int age = 20;
  String sex = "";
  String _name = "私有属性";
  // Person({String? name, String? sex, int? age}) {
  //   if(name != null) {
  //     this.username = name;
  //   }
  //   if(sex != null) {
  //     this.sex = sex;
  //   }
  //   if(age != null) {
  //     this.age = age;
  //   }
  // }
  // Person(this.username, this.age, this.sex);
  Person.createInfo({String? name, String? sex, int? age}) {
   if(name != null) {
      this.username = name;
    }
    if(sex != null) {
      this.sex = sex;
    }
    if(age != null) {
      this.age = age;
    }
  }
  run () {
   print("$username $age $sex 在跑步");
  }
  eat () {
    print( "$username $age $sex在吃饭");
  }
  sleep () {
    print( "$username $age $sex在睡觉");
  }

}